package com.gt.quality.system.mapper;

import com.gt.quality.config.handler.EasyBaseMapper;
import com.gt.quality.system.entity.SysDept;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 部门表(SysDept)表数据库访问层
 *
 * @author makejava
 * @since 2026-11-25 16:30:08
 */
@Mapper
public interface SysDeptMapper extends EasyBaseMapper<SysDept> {


    @Select("select main.dept_id,main.parent_id,main.ancestors,main.dept_name,main.dept_category,main.order_num from sys_dept main where main.dept_id = (select su.dept_id from  sys_user su where su.user_id = #{userId})")
    SysDept selectByUserId(@Param("userId") Long userId);

    @Select("select main.dept_id from  sys_role_dept main left join sys_dept sd on sd.dept_id = main.dept_id where main.role_id = #{roleId}")
    List<Long> selectDeptIdsByRoleId(@Param("roleId") Long roleId);
}

